home *** CD-ROM | disk | FTP | other *** search
- unit spkutil;
-
- interface
-
- procedure speaker_on;
- procedure speaker_off;
- procedure speaker_freq(freq:word);
- function spk_stat:byte;
-
- implementation
-
- procedure speaker_on;
- begin
- asm
- in al,61h
- or al,3
- out 61h,al
- end;
- end;
-
- procedure speaker_off;
- begin
- asm
- in al,61h
- and al,0fch
- out 61h,al
- end;
- end;
-
- procedure speaker_freq(freq:word);
- const
- timer_clock = 1193180;
- type
- wrd = record
- lo : byte;
- hi : byte;
- end;
-
- var
- count : word;
- begin
- if freq>18 then count:=round((timer_clock/freq)) else count:=0;
- asm
- pushf
- push ax
- cli
- mov al,(2 shl 6)+(3 shl 4)+(3 shl 1)+(0 shl 0)
- out 43h,al
- mov al,wrd(count).lo
- out 42h,al
- mov al,wrd(count).hi
- out 42h,al
- pop ax
- popf
- end;
- end;
-
- function spk_stat:byte;
- begin
- port[$43]:=128+64+8;{128+64+32+8;}
- spk_stat:=((port[$42]) and 128) shr 7;
- end;
-
- end.
-